﻿<html>

	<head>
		<title>快递管理</title>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">

		<link href="../../css/skin/default/style.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" href="../../css/dialog.css">
		<link href="../../js/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />

		<script src="../../js/lib/jquery/jquery-1.10.2.min.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>

		<script src="../../js/lib/ligerUI/js/plugins/ligerPopupEdit.js"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerLayout.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerForm.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerDateEditor.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerRadio.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerTextBox.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerSpinner.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerDrag.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerResizable.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerTip.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerMenu.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerToolBar.js" type="text/javascript"></script>
		<script src="../../js/JS/XHD.js" type="text/javascript"></script>
		<script src="../../js/lib/jquery.form.js" type="text/javascript"></script>
		<script src="../../js/lib/json2.js" type="text/javascript"></script>
		<script src="../../js/dialog.js"></script>
		<script src="../../js/constants.js" type="text/javascript"></script>
		<script src="../../js/api.js" type="text/javascript"></script>

		<script type="text/javascript">
			var manager;
			$(document).hover(parent.hindMenu);
			var token = $api.getStorage("token");
			var mid = $api.getparastr("mid");
			var yurl = BaseUrl+"SysExpress";
			$(function() {
				var url =yurl+"?token="+$api.getStorage("token")+"&key=";

				toolbar();
				manager = $("#maingrid4").ligerGrid({
					columns: [{
							display: '编号',
							name: 'ID',
							width: 80
						},
						{
							display: '全称',
							name: 'FullName',
							width: 280,
							align: "left"
						},
						{
							display: '名称',
							name: 'Express',
							width: 120
						},
						{
							display: '状态',
							name: 'IsUser',
							width: 120,
							render: function(rowdata, rowindex, value) {
								if(rowdata.IsUser == true) return "正在使用";
								else return "已暂停";
							}
						},
						{
							display: '优先级',
							name: 'Morder',
							width: 100
						},
						{
							display: '创建时间',
							name: 'CreateDate',
							minWidth: 120,
							type: 'date'
						}
					],
					method:'get',
					dataAction: 'local',
					url: url,
					width: '100%',
					height: '95%',
					usePager: false, //是否分页  
					onDblClickRow: function(data, rowindex, rowobj) {
						f_openWindow('vsys/tb_express/Add.html?data=' + escape(JSON.stringify(data)), "快递公司", 470, 400);

					}
				});
			});

			function toolbar() {
				$api.getLimit(mid,1, function(data) {
					$("#icon-list").append(data);
				});
			}

			function doSearch() {
				
					var key = $("#txtKeywords").val();
					var url = yurl + "?token=" + $api.getStorage("token")+"&key="+key;
 					manager.GetDataByURL(url);
				
			}

			function f_reload() {
				var manager = $("#maingrid4").ligerGetGridManager();
				manager.loadData(true);
			};

			var activeDialog = null;

			function f_openWindow(url, title, width, height) {
				var dialogOptions = {
					width: width,
					height: height,
					title: title,
					url: url,
					buttons: [{
							text: '保存',
							onclick: function(item, dialog) {
								f_save(item, dialog);
							}
						},
						{
							text: '关闭',
							onclick: function(item, dialog) {
								dialog.close();
							}
						}
					],
					isResize: true,
					timeParmName: 'a'
				};
				var dialog = top.jQuery.ligerDialog;
				dialog.open(dialogOptions);
			}

			function add() {
				f_openWindow('vsys/tb_express/Add.html', "快递公司", 470, 400);
			}

			function edit() {
				var manager = $("#maingrid4").ligerGetGridManager();
				var row = manager.getSelectedRow();
				if(row) {
					f_openWindow('vsys/tb_express/Add.html?data=' + escape(JSON.stringify(row)), "快递公司", 470, 400);
				} else {
					$.ligerDialog.warn("请选择行");
				}
			}

			function del() {

				var manager = $("#maingrid4").ligerGetGridManager();
				var row = manager.getSelectedRow();

				if(row) { 
					$.ligerDialog.confirm("快递删除后不能恢复，\n您确定要移除？", function(yes) {
						if(yes) {
						
							
							var url = yurl+"?token="+token+"&action=del";
							 
							$api.ajax2(url,row,function(data){
									f_reload();
							}); 
						}
					})
				} else {
					$.ligerDialog.warn("请选择行！");
				}

			}

			function f_save(item, dialog) {
				var row = dialog.frame.f_save();
				if(row) {
					dialog.close(); 
					
					var url = yurl+"?token="+token+"&action="+row.action;
					$api.ajax2(url,row.data,function(data){
									f_reload();
							}); 
					}
			}
		</script>

	</head>

	<body class="mainbody">
		<form id="form1" onsubmit="return false">
			<div>
				<div class="toolbar-wrap">
					<div  class="toolbar">
						<div class="l-list">
							<ul id="icon-list" class="icon-list">
							</ul>
						</div>
						<div class="r-list">
							 <input type="text" placeholder="输入关键字搜索" ID="txtKeywords" class="keyword" />
							 <a class='btn-search' onclick='doSearch();'></a>
						</div>
					</div>
				</div>
				<div id="maingrid4" style="margin: 0px;background:#fff;"></div>
			</div>
		</form>

	</body>

</html>